const Controllers = require('../controllers/Controller.js').controller;
const app = getApp();
Page({
  data: {
    globalStype:'',
  	memberGoodsPagedata:[],
    pageNumber:1,
    pageSize:10,
    isEnd:false,
    isloading:true,
    shopId:'',
  },
  onLoad(option) {
    this.setData({globalStype:app.globalData.globalStype})
  	if(app.globalData.shopId){
      this.setData({
        'malllists[0].shopTypeId':app.globalData.shopId,
        shopId:app.globalData.shopId,
      })
      this.memberGoodsPage()
    }
  },
  memberGoodsPage(){
    Controllers.memberGoodsPage({
      pageSize:this.data.pageSize,
      pageNumber:this.data.pageNumber,
      shopId:this.data.shopId
    }).then(res => {
      if(res.data.list.length>0){
        for(let item of res.data.list){
          if(item.label)
          item.label=item.label.split('/')
        }
        this.setData({
          memberGoodsPagedata:this.data.memberGoodsPagedata.concat(res.data.list),

        })
        
      }
      if(res.data.lastPage){
          this.setData({
            isEnd:true
          })
        }
      this.setData({
        isloading:false
      })
    });
  },
  onReachBottom() {
    if (this.data.isEnd) {
      return;
    } else {
      this.setData({
          pageNumber: this.data.pageNumber + 1,
      });
      this.memberGoodsPage()
    }
  },
})